package com.boot.security.server.service.impl.mffl.MfflService;

import com.boot.security.server.dao.mffl.MfflServiceDao;
import com.boot.security.server.model.mffl.MfflService;
import com.boot.security.server.model.mffl.Vo.MfflServiceVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * 服务类型
 */
@Service
public class MfflServiceImpl {
    /**
     * 服务
     */
    @Autowired
    private MfflServiceDao MfflServiceDao;


    //通过id获取服务数据
    public MfflService getByServiceId(Long id) {
        return MfflServiceDao.getByServiceId(id);
    }

    //修改信息
    public MfflServiceVo update(MfflServiceVo mfflService){
        if (!StringUtils.isEmpty(mfflService.getConfirmTime())) {
            mfflService.setConfirmTime(String.valueOf((((Long.parseLong(mfflService.getConfirmTime()) * 24) * 60) * 60) * 1000));
        }
        if (!StringUtils.isEmpty(mfflService.getRefuseTime())) {
            mfflService.setRefuseTime(String.valueOf((((Long.parseLong(mfflService.getRefuseTime()) * 24) * 60) * 60) * 1000));
        }
        if (mfflService.getFreeapplytime() != null && mfflService.getFreeapplytime() != 0) {
            mfflService.setFreeapplytime((mfflService.getFreeapplytime() * 60) * 1000);
        }
        MfflServiceDao.update(mfflService);
        return mfflService;
    }
}

